package com.cet.qz.unit01.chapter1_2;

import edu.princeton.cs.algs4.StdIn;

/**
 * @program: algorithm
 * @description:
 * @author: 陈恩涛
 * @create: 2021-03-03 17:15
 **/
public class Qz1_2_7 {

    public static String mystery(String s) {
        int N = s.length();
        if (N <= 1) {
            return s;
        }
        String a = s.substring(0, N / 2);
        String b = s.substring(N / 2, N);
        return mystery(b) + mystery(a);
    }

    public static void main(String[] args) {
        System.out.println("请输入一个字符串:");
        String s = StdIn.readString();
        System.out.println(mystery(s));
    }
}
